﻿using System.IO;
using Nivot.PowerShell.WindowsMobile.Rapi2;

namespace Nivot.PowerShell.WindowsMobile
{
    internal class CEObjectFactory
    {
        internal static CEObject CreateCEObject(RemoteDevice device, string devicePath)
        {
            CEObject ceObject;
            if (Path.HasExtension(devicePath))
            {
                switch (Path.GetExtension(devicePath).ToLower())
                {
                    case ".jpg":
                    case ".gif":
                    case ".png":
                    case ".bmp":
                        ceObject = new CEImageFile(device, devicePath);
                        break;

                    case ".mp4":
                    case ".wmv":
                    case ".mpg":
                        ceObject = new CEVideoFile(device, devicePath);
                        break;

                    case ".wav":
                    case ".mp3":
                    case ".mid":
                        ceObject = new CEAudioFile(device, devicePath);
                        break;

                    case ".exe":
                    case ".com":
                    case ".lnk":
                        ceObject = new CEExecutableFile(device, devicePath);
                        break;

                    default:
                        ceObject = new CEFile(device, devicePath);
                        break;
                }
            }
            else
            {
                ceObject = new CEFile(device, devicePath);
            }
            return ceObject;
        }
    }
}